﻿/*****************************************************************//**
 * @file    FITKGraphObjectPredefinedFieldVelocity.h
 * @brief   Graph object base for velocity predefined field
 *
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-07-04
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTPREDEFINEDFIELDVELOCITY_H__
#define __FITKGRAPHOBJECTPREDEFINEDFIELDVELOCITY_H__

#include "FITKGraphObjectPredefinedFieldBase.h"

#include "FITKVTKGraphAdaptorAPI.h"

 // Forward declaration
class vtkArrowSource;
class vtkDoubleArray;

class FITKGraphActor;

namespace Interface
{
    class FITKAbaPredefinedFieldVelocity;
}

namespace Exchange
{
    /**
     * @brief   Graph object base for velocity predefined field.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-07-04
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectPredefinedFieldVelocity : public FITKGraphObjectPredefinedFieldBase
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectPredefinedFieldVelocity, FITKGraphObjectPredefinedFieldBase);
        FITKCLASS(Exchange, FITKGraphObjectPredefinedFieldVelocity);

    public:
        /**
         * @brief   Constructor.
         * @param   caseData: The case data
         * @param   fieldData: The predefined field data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        FITKGraphObjectPredefinedFieldVelocity(AbaqusData::FITKDataCase* caseData, Interface::FITKAbaPredefinedFieldVelocity* fieldData);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        virtual ~FITKGraphObjectPredefinedFieldVelocity();

        /**
         * @brief   Highlight the predefined field graph actors.[virtual][override]
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        virtual void highlight(QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the predefined field graph actors.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        virtual void disHighlight() override;

        /**
         * @brief   Set the render, which will add this graph object to itself.( for calculating size )[override]
         * @param   render: The FITKGrapgRender
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        void setFITKRender(Comp::FITKGraphRender* render) override;

    private:
        /**
         * @brief   Initialize.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        void init() override;

        /**
         * @brief   Initialize the actors.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        void initActors() override;

        /**
         * @brief   Check if the data has been changed.[override]
         * @return  Is data changed
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        bool dataChanged() override;

        /**
         * @brief   Generate the grid data for the predefined field.[override]
         * @param   fieldData: The predefined field data object
         * @return  Is OK
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        bool generatePolyData(Interface::FITKAbaAbstractPredefinedField* fieldData) override;

        /**
         * @brief   Generate predefined field actor.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        void generateGraph() override;

        /**
         * @brief   Clear the data.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        void clearData() override;

    private:
        /**
         * @brief   The glyph source for the velocity field.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        vtkArrowSource* m_arrowSource{ nullptr };

        /**
         * @brief   The normal data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        vtkDoubleArray* m_normal{ nullptr };

        /**
         * @brief   The scalar data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        vtkDoubleArray* m_scalar{ nullptr };

        /**
         * @brief   The value of velocity.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-04
         */
        double m_value[3]{ 0, 0, 0 };
    
    };
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTPREDEFINEDFIELDVELOCITY_H__
